<template>
	<view>
		<view class="">
			<cartTitle text="购物信息"></cartTitle>
		</view>
		<view class="content">
			<view class="">
				<selfCode @inputChang="taobaozhanghao" lable="淘宝账号" :inputValue="user.taobaoZhanghao" type="input" placeholder="请填写"
				 :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx" dongLabelpaddingTop="0"></selfCode>
			</view>
			<view class="">
				<selfCode @inputChang="taobaoiddengji" lable="账号等级" type="picker" borderBottom="unset" dictType="taobao_zhanghao_dengji"
				 :pickerVal="user.taobaoDengji" dongLabelpaddingTop="12rpx" dongLabelpaddingRight="22rpx"></selfCode>

			</view>
		</view>
		<view class="content">
			<view class="">
				<selfCode @inputChang="jingdongzhnaghao" lable="京东账号" :inputValue="user.jingdongZhanghao" type="input" placeholder="请填写"
				 :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx" dongLabelpaddingTop="0"></selfCode>
			</view>
			<view class="">
				<selfCode @inputChang="jingdongdengji" lable="账号等级" type="picker" borderBottom="unset" dictType="jd_zhanghao_dengji"
				 :pickerVal="user.jingdongDengji" dongLabelpaddingTop="12rpx" dongLabelpaddingRight="22rpx"></selfCode>
			</view>
		</view>
		<view class="content">
			<view class="">
				<selfCode @inputChang="pinduoduozhanghao" lable="拼多多账号" borderBottom="unset" :inputValue="user.pinduoduoZhanghao"
				 type="input" placeholder="请填写" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx" dongLabelpaddingTop="0"></selfCode>
			</view>
		</view>
		<view class="content">
			<view class="">
				<selfCode @inputChang="shouhuodizhi" lable="收货地址" borderBottom="unset" :inputValue="user.shouhuoAddr" type="input"
				 placeholder="请填写收货地址" :qianjin="false" dongLabelFontColor="#191919" dongLabelpaddingRight="36rpx" dongLabelpaddingTop="0"></selfCode>
			</view>
		</view>
		<view class="" style="padding:0 54rpx 80rpx;">
			<submitButtom text="保存" :buttonMethod="submit"></submitButtom>
		</view>
		<selfPopupMessage ref="selfPopupMessage"></selfPopupMessage>
		<u-toast :type="toastType" ref="uToast"></u-toast>
	</view>
</template>

<script>
	import cartTitle from '@/components/self-cart-title/self-cart-title.vue'
	import selfCode from "@/components/self-card/self-card.vue"
	import submitButtom from "@/components/submit-button/submit-button.vue"
	export default {
		components: {
			cartTitle,
			selfCode,
			submitButtom
		},
		data() {
			return {
				taobaodengjiarray: [],
				jingdongarray: [],
				user: {
					taobaoZhanghao: "",
					taobaoDengji: "",
					jingdongZhanghao: "",
					jingdongDengji: "",
					pinduoduoZhanghao: "",
					shouhuoAddr: ""
				}
			}
		},
		onLoad() {
			var userinfo = uni.getStorageSync("userInfo");
			this.user = userinfo;
		},
		methods: {
			inputChang: function(value, name) {
				console.log(value);
				this.user[name] = value;
			},
			submit: function() {
				console.log(JSON.stringify(this.user));
				var that = this;
				var id = uni.getStorageSync("token");
				this.user.userId = id;
				this.$util.nuiAjax(this.$jiekou.updateUser, this.user, function(res) {
					if (res.result == "true") {
						
						uni.$emit("update_user");
						
						that.$refs.uToast.show({
							title: "发布成功",
							duration:500,
							callback:function(){
								uni.navigateBack({
									delta: 2
								});
							}
						});
					} else {
						// that.$refs.selfPopupMessage.open(res.message);
						that.$refs.uToast.show({
							title: res.message,
							duration:2000,
						
						});
					}
				})
			},
			taobaoiddengji: function(value) {
				this.user.taobaoDengji = value;
			},
			jingdongdengji: function(value) {
				this.user.jingdongDengji = value;
			},
			taobaozhanghao: function(value) {
				this.user.taobaoZhanghao = value;
			},
			jingdongzhnaghao: function(value) {
				this.user.jingdongZhanghao = value;
			},
			pinduoduozhanghao: function(value) {
				this.user.pinduoduoZhanghao = value;
			},
			shouhuodizhi: function(value) {
				this.user.shouhuoAddr = value;
			},

		}
	}
</script>

<style>
	page {
		background-color: $page-bg-color;
	}

	.content {
		box-shadow: 0px 8px 16px 0px rgba(246, 247, 248, 1);
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
	}
</style>
